package com.thingcom.delinrobot.base;

import android.app.Activity;
import android.os.Bundle;

import androidx.annotation.Nullable;

import com.thingcom.delinrobot.R;
import com.thingcom.delinrobot.utils.Density;

import java.util.LinkedList;
import java.util.List;

import me.yokeyword.fragmentation.SupportActivity;

/**
 * author : YuFeng
 * e-mail : 923462992@qq.com
 * date   : 2019/10/30
 */
public class BaseActivity extends SupportActivity {
    private static final String TAG = "BaseActivity";
    private static List<BaseActivity> activityList = new LinkedList<>();
    protected Activity mActivity;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        getWindow().setStatusBarColor(getResources().getColor(R.color.black_main));
        super.onCreate(savedInstanceState);
        mActivity = this;
        setOrientation();
        activityList.add(this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        activityList.remove(this);
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    public void setOrientation(){
        Density.setDefault(mActivity);
    }

    public static void destroyAllOnExit(){
        for (BaseActivity baseActivity : activityList) {
            baseActivity.finish();
            activityList.remove(baseActivity);
        }
    }

}
